# utils/file_utils.py
import os
import hashlib
from typing import List, Dict, Any


def get_file_hash(file_path: str) -> str:
    """计算文件哈希值"""
    hasher = hashlib.md5()
    with open(file_path, 'rb') as f:
        buf = f.read()
        hasher.update(buf)
    return hasher.hexdigest()


def validate_document(file_path: str) -> bool:
    """验证文档文件"""
    if not os.path.exists(file_path):
        print(f"❌ 文件不存在: {file_path}")
        return False

    file_size = os.path.getsize(file_path)
    if file_size == 0:
        print(f"❌ 文件为空: {file_path}")
        return False

    if file_size > 10 * 1024 * 1024:  # 10MB
        print(f"❌ 文件过大: {file_size} bytes")
        return False

    return True


def print_system_info():
    """打印系统信息"""
    import platform
    import sys

    print("=" * 50)
    print("系统信息")
    print("=" * 50)
    print(f"操作系统: {platform.system()} {platform.release()}")
    print(f"Python版本: {platform.python_version()}")
    print(f"工作目录: {os.getcwd()}")
    print("=" * 50)